import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;


public class StatistieksView extends JPanel implements ActionListener
{
		private DobbelsteenModel d;
		private ArrayList<JLabel> xList	=	new ArrayList<JLabel>();
		private int[] xNumber				=	new int[]{0,0,0,0,0,0,0};
		
	/**
	 * Constructor	
	 */
	public StatistieksView()
	{
		setLayout(new GridLayout(7,1));
		for (int i=0; i<7; i++)
		{
			xList.add(new JLabel(" "+(i+1)+" :   0"));
		}
		for (JLabel b:	xList)
		{
			add(b);
		}
	}
	
	/**
	 * Luister naar event.
	 */
	@Override
	public void actionPerformed(ActionEvent e)
	{
		d 			= 	(DobbelsteenModel) e.getSource();
		int i 		= 	d.getWaarde();
		
		xNumber[i-1]++;
		xNumber[6]++;
		
		for (int q=0; q<xList.size(); q++)
		{
			xList.get(q).setText(" "+(q+1)+" :   "+xNumber[q]);
		}
		xList.get(6).setText(" "+xNumber[6]+" geworpen");
	}
	
	/**
	 * Resize de grote van de view.
	 */
	public Dimension getPreferredSize()
	{
		return new Dimension(100, 50);
	}  
}